<?php

//error_reporting(E_ERROR | E_WARNING | E_PARSE);
mysql_connect(localhost, root, root);
@mysql_select_db(comzs) or die("Unable to select database");
set_time_limit(0);
ini_set("memory_limit", "200M");
//$dateTime = date("Y-m-d",strtotime("-1 day"));
//$handle = fopen("http://192.168.0.185/log/test/$dateTime.'a'", "r");
$handle = fopen("/root/backup/log/comzs/log", "r");
while (!feof($handle)) {
    $buffer = fgets($handle, 10960);
    // $array[] = $buffer;
    $arr = json_decode($buffer, true);
    $id100 = $arr["data"];
    $arr2 = json_decode($id100, true);


    $id = $arr2["AvatarUseData_Pirate"];
    $id2 = $arr2["Cur_Avatar"];
    $id3 = $arr2["WeaponUseData_PGM"];
    $id4 = $arr2["SceneEnter_ShopMenuTUI"];
    $id5 = $arr2["WeaponUseData_RPG-7"];
    $id6 = $arr2["WeaponUseData_XM-1014"];
    $id7 = $arr2["WeaponUseData_Remington-870"];
    $id8 = $arr2["SceneEnter_AvatarShopMenuTUI"];
    $id9 = $arr2["TotalTime"];
    $id10 = $arr2["WeaponUseData_LightSword"];

    $id11 = $arr2["SceneEnter_Zombie3D_PowerStation"];  
    $id12 = $arr2["SceneEnter_EquipMenuTUI"];
    $id13 = $arr2["CurDay"];
    $id14 = $arr2["WeaponUseData_Chainsaw"];
    $id15 = $arr2["Iap_Buy_Count_1"]; 
    $id16 = $arr2["AvatarUseData_Marine"];
    $id17 = $arr2["MissionFailed_Day_17"];
    $id18 = $arr2["CashSpendBullets"];
    $id19 = $arr2["SceneEnter_UpgradeTUI"]; 
    $id20 = $arr2["AvatarUseData_Cowboy"];


    $id21 = $arr2["AvatarUseData_Swat"];
    $id22 = $arr2["BulletsBuy_MP5_BuyBullet"];
    $id23 = $arr2["AvatarUseData_Human"];
    $id24 = $arr2["CashLoot"];


    $id25 = $arr2["DataTime"];
    $id26 = $arr2["CoopCount"];
    $id27 = $arr2["AvatarUseData_EnegyArmor"];
    $id28 = $arr2["CashSpendWeapons"];
    $id29 = $arr2["AvatarUseData_Worker"];
    $id30 = $arr2["WeaponUseData_HellFire"];
    $id31 = $arr2["WeaponUseData_Gatling"];
    $id32 = $arr2["Iap_Buy_Count_4"];
    $id33= $arr2["Iap_Buy_Count_5"];
    $id34 = $arr2["AvatarUseData_Doctor"];

    $id35 = $arr2["SceneEnter_Zombie3D_Recycle"];  
    $id36 = $arr2["LastDayState"];
    //$id37 = $arr2["Day_17_Failed"];
    $id38 = $arr2["WeaponOwner_0"];
    $id39 = $arr2["WeaponUseData_Winchester-1200"]; 
    $id40 = $arr2["TotalMoneyGet"];
    $id41 = $arr2["WeaponOwner_3"];
    $id42 = $arr2["WeaponOwner_4"];
    $id43 = $arr2["WeaponOwner_1"]; 
    $id44 = $arr2["WeaponOwner_2"];


    $id45 = $arr2["Iap_Buy_Count_0"];
    $id46 = $arr2["CashCurrent"];
    $id47 = $arr2["Iap_Buy_Count_2"];
    $id48 = $arr2["FirstStatisticsTimeNew"];

    $id49 = $arr2["Cur_Weapon_0"];
    $id50 = $arr2["Cur_Weapon_1"];
    $id51= $arr2["Cur_Weapon_2"];
    $id52 = $arr2["CashIap"];
    $id53 = $arr2["AvatarUseData_Nerd"];
    $id54 = $arr2["WeaponOwner_2_avatarUseData_Nerd"];
    $id55 = $arr2["PlayTime"];
    $id56 = $arr2["WeaponUseData_M32"];
    $id57 = $arr2["SceneEnter_NickNameTUI"];
    $id58 = $arr2["AvatarUseData_Pastor"];

    $id59 = $arr2["WeaponUseData_Laser"];  
    $id60 = $arr2["WeaponUseData_AUG"];
    $id61 = $arr2["AvatarUseData_Eskimo"];
    $id62 = $arr2["SceneEnter_StartMenuUI"];
    $id63 = $arr2["Iap_Buy_Count_3"]; 
    $id64 = $arr2["SceneEnter_PaperJoyShowUI"];
    $id65 = $arr2["AvatarUseData_Ninja"];
    $id66 = $arr2["AppCount"];
    $id67 = $arr2["WeaponUseData_P90"]; 
    $id68 = $arr2["SceneEnter_NetMapTUI"];

    $id69 = $arr2["SceneEnter_RoomOwnerTUI"];
    $id70 = $arr2["WeaponUseData_AK-47"];
    $id71 = $arr2["DayCount"];
    $id72 = $arr2["WeaponUseData_M4"];


    $id73 = $arr2["AchivmentCount"];
    $id74 = $arr2["CashSpend"];
    $id75 = $arr2["SceneEnter_MultiplayRoomTUI"];
    $id76 = $arr2["SceneEnter_MainMapTUI"];
    $id77 = $arr2["WeaponUseData_MP5"];
    $id78 = $arr2["IsJailbreak"];
    $id79 = $arr2["ConsumeContent0"];
    $id80 = $arr2["ConsumeContent1"];
    $id81 = $arr2["SceneEnter_Zombie3D_Village"];
    $id82 = $arr2["SceneEnter_Zombie3D_Arena"];

    $id83 = $arr2["BulletsBuy_Remington-870_BuyBullet"]; 
    $id84 = $arr2["BulletsBuy_M4_BuyBullet"];
    $id85 = $arr2["WeaponUp_M4_Power"];
    $id86 = $arr2["WeaponOwner_5"];
    $id87 = $arr2["SceneEnter_Zombie3D_Village2"]; 
    $id88 = $arr2["WeaponUseData_M4_sceneEnter_Zombie3D_Village2"];
    $id90 = $arr2["WeaponUp_AUG_Accuracy"];
    $id91 = $arr2["SceneEnter_Zombie3D_ParkingLot"];
    $id92 = $arr2["WeaponUp_M4_Accuracy"]; 
    $id93 = $arr2["BulletsBuy_AUG_BuyBullet"];


    $id94 = $arr2["WeaponUp_AUG_Frequency"];
    $id95 = $arr2["WeaponUp_M4_Frequency"];
    $id96 = $arr2["BulletsBuy_Winchester-1200_BuyBullet"];
    $id97 = $arr2["BulletsBuy_AK-47_BuyBullet"];

    $id98 = $arr2["SceneEnter_Zombie3D_Hospital"];
    $id99 = $arr2["UserId"];
    $id100 = $arr["gamename"];
    $id101 = $arr["createdate"];
    $id102 = $arr["WeaponUseData_ElectricGun"];


    $s = 0;
    foreach ((array) $arr as $item => $value) {   //Warning: Invalid argument supplied for foreach
        $s = count($value); 
    }
    for ($i = 0; $i < $s; $i++) {
    	
        $AvatarUseData_Pirate = $id;
        $Cur_Avatar = $id2;
        $WeaponUseData_PGM = $id3;
        $SceneEnter_ShopMenuTUI = $id4;
        $WeaponUseData_RPG_7 = $id5;
        $WeaponUseData_XM_1014 = $id6;
        $WeaponUseData_Remington_870 = $id7;
        $SceneEnter_AvatarShopMenuTUI = $id8;
        $TotalTime = $id9;
        $WeaponUseData_LightSword = $id10;
        $SceneEnter_Zombie3D_PowerStation = $id11;
        $SceneEnter_EquipMenuTUI = $id12;
        $CurDay = $id13;
        $WeaponUseData_Chainsaw = $id14;
        $Iap_Buy_Count_1 = $id15;
        $AvatarUseData_Marine = $id16;
        $MissionFailed_Day_17 = $id17;
        $CashSpendBullets = $id18;
        $SceneEnter_UpgradeTUI = $id19;
        $AvatarUseData_Cowboy = $id20;
        $AvatarUseData_Swat = $id21;
        $BulletsBuy_MP5_BuyBullet = $id22;
        $AvatarUseData_Human = $id23;
        $CashLoot = $id24;
        


       $DataTime = $id25;
       $CoopCount = $id26 ;
       $AvatarUseData_EnegyArmor = $id27;
       $CashSpendWeapons = $id28;
       $AvatarUseData_Worker = $id29;
       $WeaponUseData_HellFire = $id30 ;
       $WeaponUseData_Gatling_870 = $id31;
       $Iap_Buy_Count_4 =  $id32 ;
       $Iap_Buy_Count_5 = $id33;
       $AvatarUseData_Doctor = $id34;

       $SceneEnter_Zombie3D_Recycle = $id35; 
       $LastDayState = $id36 ;
      //$Day_17_Failed = $id37;
       $WeaponOwner_0 = $id38 ;
       $WeaponUseData_Winchester_1200 = $id39; 
       $TotalMoneyGet = $id40;
       $WeaponOwner_3 = $id41;
       $WeaponOwner_4 =  $id42;
       $WeaponOwner_1 =  $id43; 
       $WeaponOwner_2 = $id44;


       $Iap_Buy_Count_0 =  $id45;
       $CashCurrent = $id46;
       $Iap_Buy_Count_2 = $id47;
       $FirstStatisticsTime = substr($id48,0,10);

       $Cur_Weapon_0 = $id49;
       $Cur_Weapon_1 = $id50;
       $Cur_Weapon_2 = $id51;
       $CashIap = $id52;
       $AvatarUseData_Nerd =  $id53 ;
       $WeaponOwner_2_avatarUseData_Nerd =  $id54;
       $PlayTime =  $id55 ;
       $WeaponUseData_M32 =   $id56;
       $SceneEnter_NickNameTUI = $id57;
       $AvatarUseData_Pastor = $id58 ;

       $WeaponUseData_Laser = $id59 ; 
       $WeaponUseData_AUG = $id60 ;
       $AvatarUseData_Eskimo =  $id61;
       $SceneEnter_StartMenuUI = $id62;
       $Iap_Buy_Count_3 =  $id63; 
       $SceneEnter_PaperJoyShowUI =  $id64 ;
       $AvatarUseData_Ninja = $id65;
       $AppCount = $id66 ;
       $WeaponUseData_P90 = $id67; 
       $SceneEnter_NetMapTUI = $id68 ;

       $SceneEnter_RoomOwnerTUI =  $id69 ;
       $WeaponUseData_AK_47 = $id70;
       $DayCount = $id71;
       $WeaponUseData_M4 = $id72 ;


       $AchivmentCount =  $id73;
       $CashSpend = $id74;
       $SceneEnter_MultiplayRoomTUI = $id75;
       $SceneEnter_MainMapTUI =  $id76 ;
       $WeaponUseData_MP5 = $id77;
       $IsJailbreak = $id78;
       $ConsumeContent0 = $id79;
       $ConsumeContent1 = $id80 ;
       $SceneEnter_Zombie3D_Village = $id81 ;
       $SceneEnter_Zombie3D_Arena = $id82;

       $BulletsBuy_Remington_870_BuyBullet = $id83 ; 
       $BulletsBuy_M4_BuyBullet = $id84 ;
       $WeaponUp_M4_Power = $id85 ;
       $WeaponOwner_5 =  $id86 ;
       $SceneEnter_Zombie3D_Village2 = $id87;
       $WeaponUseData_M4_sceneEnter_Zombie3D_Village2 =  $id88;
       $WeaponUp_AUG_Accuracy = $id90;
       $SceneEnter_Zombie3D_ParkingLot =  $id91 ;
       $WeaponUp_M4_Accuracy = $id92;
       $BulletsBuy_AUG_BuyBullet =$id93 ;


       $WeaponUp_AUG_Frequency = $id94;
       $WeaponUp_M4_Frequency = $id95 ;
       $BulletsBuy_Winchester_1200_BuyBullet =$id96;
       $BulletsBuy_AK_47_BuyBullet = $id97 ;

       $SceneEnter_Zombie3D_Hospital = $id98 ;
       $deviceid = $id99;
       $gamename = $id100;
       $createdate = $id101;
       $WeaponUseData_ElectricGun =$id102;

   

        mysql_query("INSERT INTO comzs_query (avatarUseData_Pirate, cur_Avatar,weaponUseData_PGM,sceneEnter_ShopMenuTUI,weaponUseData_RPG_7,cashSpendBullets,
                                        weaponUseData_XM_1014,weaponUseData_Remington_870,sceneEnter_AvatarShopMenuTUI,totalTime,weaponUseData_LightSword,sceneEnter_Zombie3D_PowerStation,sceneEnter_EquipMenuTUI,
                                        curDay,weaponUseData_Chainsaw,iap_Buy_Count_1,avatarUseData_Marine,missionFailed_Day_17,sceneEnter_UpgradeTUI,avatarUseData_Cowboy,
                                        avatarUseData_Swat,bulletsBuy_MP5_BuyBullet,avatarUseData_Human,cashLoot,coopCount,avatarUseData_EnegyArmor,cashSpendWeapons,
                                        avatarUseData_Worker,weaponUseData_HellFire, weaponUseData_Gatling ,iap_Buy_Count_4,iap_Buy_Count_5 ,avatarUseData_Doctor,
                                        sceneEnter_Zombie3D_Recycle ,lastDayState,weaponOwner_0 ,weaponUseData_Winchester_1200 ,totalMoneyGet,weaponOwner_3 ,
                                        weaponOwner_4 ,weaponOwner_1,weaponOwner_2 ,iap_Buy_Count_0,cashCurrent ,iap_Buy_Count_2,firstStatisticsTime ,cur_Weapon_0,cur_Weapon_1 ,cur_Weapon_2 ,
                                        cashIap ,avatarUseData_Nerd ,weaponOwner_2_avatarUseData_Nerd,playTime,weaponUseData_M32 ,sceneEnter_NickNameTUI ,avatarUseData_Pastor,
                                        weaponUseData_Laser ,weaponUseData_AUG ,avatarUseData_Eskimo ,sceneEnter_StartMenuUI,iap_Buy_Count_3,sceneEnter_PaperJoyShowUI,
                                        avatarUseData_Ninja ,appCount ,weaponUseData_P90,sceneEnter_NetMapTUI ,sceneEnter_RoomOwnerTUI,weaponUseData_AK_47,dayCount,
                                        weaponUseData_M4,achivmentCount,cashSpend,sceneEnter_MultiplayRoomTUI,sceneEnter_MainMapTUI ,weaponUseData_MP5,
                                        isJailbreak,consumeContent0 ,consumeContent1,sceneEnter_Zombie3D_Village,SceneEnter_Zombie3D_Arena ,
                                        BulletsBuy_Remington_870_BuyBullet,BulletsBuy_M4_BuyBullet,weaponUp_M4_Power ,weaponOwner_5 ,
                                        sceneEnter_Zombie3D_Village2,weaponUseData_M4_sceneEnter_Zombie3D_Village2 ,weaponUp_AUG_Accuracy,sceneEnter_Zombie3D_ParkingLot,
                                        weaponUp_M4_Accuracy ,bulletsBuy_AUG_BuyBullet ,weaponUp_AUG_Frequency ,weaponUp_M4_Frequency,bulletsBuy_Winchester_1200_BuyBullet,
                                        bulletsBuy_AK_47_BuyBullet ,sceneEnter_Zombie3D_Hospital ,deviceid,gamename,createdate,date,DataTime,firstLogin,WeaponUseData_ElectricGun) 
                    VALUES('$AvatarUseData_Pirate','$Cur_Avatar','$WeaponUseData_PGM','$SceneEnter_ShopMenuTUI','$WeaponUseData_RPG_7','$CashSpendBullets',
                        '$WeaponUseData_XM_1014','$WeaponUseData_Remington_870','$SceneEnter_AvatarShopMenuTUI','$TotalTime','$WeaponUseData_LightSword','$SceneEnter_Zombie3D_PowerStation','$SceneEnter_EquipMenuTUI',
                           '$CurDay','$WeaponUseData_Chainsaw','$Iap_Buy_Count_1','$AvatarUseData_Marine','$MissionFailed_Day_17','$SceneEnter_UpgradeTUI','$AvatarUseData_Cowboy',
                           '$AvatarUseData_Swat','$BulletsBuy_MP5_BuyBullet',
                           '$AvatarUseData_Human','$CashLoot','$CoopCount','$AvatarUseData_EnegyArmor','$CashSpendWeapons',
                           '$AvatarUseData_Worker','$WeaponUseData_HellFire','$WeaponUseData_Gatling_870 ','$Iap_Buy_Count_4','$Iap_Buy_Count_5','$AvatarUseData_Doctor','$SceneEnter_Zombie3D_Recycle ','$LastDayState',
                           '$WeaponOwner_0 ','$WeaponUseData_Winchester_1200 ','$TotalMoneyGet','$WeaponOwner_3 ','$WeaponOwner_4','$WeaponOwner_1','$WeaponOwner_2 ',
                           '$Iap_Buy_Count_0','$CashCurrent ','$Iap_Buy_Count_2','$FirstStatisticsTime ','$Cur_Weapon_0','$Cur_Weapon_1 ','$Cur_Weapon_2 ','$CashIap ','$AvatarUseData_Nerd',
                           '$WeaponOwner_2_avatarUseData_Nerd','$PlayTime','$WeaponUseData_M32','$SceneEnter_NickNameTUI ','$AvatarUseData_Pastor','$WeaponUseData_Laser ','$WeaponUseData_AUG',
                           '$AvatarUseData_Eskimo','$SceneEnter_StartMenuUI ','$Iap_Buy_Count_3','$SceneEnter_PaperJoyShowUI','$AvatarUseData_Ninja','$AppCount','$WeaponUseData_P90',
                           '$SceneEnter_NetMapTUI','$SceneEnter_RoomOwnerTUI','$WeaponUseData_AK_47','$DayCount','$WeaponUseData_M4 ','$AchivmentCount','$CashSpend','$SceneEnter_MultiplayRoomTUI',
                           '$SceneEnter_MainMapTUI','$WeaponUseData_MP5 ','$IsJailbreak','$ConsumeContent0','$ConsumeContent1','$SceneEnter_Zombie3D_Village','$SceneEnter_Zombie3D_Arena ',
                           '$BulletsBuy_Remington_870_BuyBullet','$BulletsBuy_M4_BuyBullet','$WeaponUp_M4_Power ','$WeaponOwner_5 ','$SceneEnter_Zombie3D_Village2','$WeaponUseData_M4_sceneEnter_Zombie3D_Village2 ',
                           '$WeaponUp_AUG_Accuracy','$SceneEnter_Zombie3D_ParkingLot ','$WeaponUp_M4_Accuracy ','$BulletsBuy_AUG_BuyBullet ','$WeaponUp_AUG_Frequency ','$WeaponUp_M4_Frequency',
                           '$BulletsBuy_Winchester_1200_BuyBullet','$BulletsBuy_AK_47_BuyBullet ','$SceneEnter_Zombie3D_Hospital ','$deviceid ','$gamename','$createdate','$createdate','$DataTime','$FirstStatisticsTime','$WeaponUseData_ElectricGun')") or die(mysql_error());
    }
}
fclose($handle);
//fclose($fp);
print "Import successful!<br>";

?>
